using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;

namespace Evaluant.EussDSL
{
    /// <summary>
    /// Class used to prevent the user from using the "Del" key or the "Delete" menu command when
    /// on an inheritance connector : the inheritance connectors are always created and deleted programmatically
    /// </summary>
    partial class EussDSLCommandSet
    {
        /// <summary>
        /// Override to stop the "Delete" command appearing for InheritanceConnectors
        /// </summary>
        /// 
        protected override void ProcessOnStatusDeleteCommand(MenuCommand command)
        {
            if (CurrentSelectionContainsInheritanceConnector())
            {
                // Disable the menu command
                command.Enabled = false;
                command.Visible = false;
            }
            else
            {
                // Otherwise, delegate to the base method.
                base.ProcessOnStatusDeleteCommand(command);
            }
        }

        private bool CurrentSelectionContainsInheritanceConnector()
        {
            foreach (object item in this.CurrentDocumentSelection)
            {
                if (item.GetType() == typeof(InheritanceConnector))
                {
                    return true;
                }
            }
            return false;
        }

    }
}
